/*
 * author      : 吴中勤 
 * date        : 2018/12/18
 * description : TODO
 */

package org.wzq.learn;

import java.util.ArrayList;
import java.util.List;

/*

【build】
javac src/org/wzq/learn/RuntimeConstantPoolOOM.java
cd src
java -Xms20M -Xmx20M -Xmn10M -XX:+PermSize=10M -XX:MaxPermSize=10M org/wzq/learn/RuntimeConstantPoolOOM

【output】
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=10M; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=10M; support was removed in 8.0
Exception in thread "main" java.lang.OutOfMemoryError: GC overhead limit exceeded
        at java.lang.Integer.toString(Integer.java:401)
        at java.lang.String.valueOf(String.java:3099)
        at org.wzq.learn.RuntimeConstantPoolOOM.main(RuntimeConstantPoolOOM.java:23)

https://blog.csdn.net/oncealong/article/details/51648676
http://openjdk.java.net/jeps/122
Remove the Permanent Generation

类的元数据, 字符串池, 类的静态变量将会从永久代移除, 放入Java heap或者native memory
*/


/**
 * 这个测试已经无效了 > jdk 1.8
 * https://blog.csdn.net/oncealong/article/details/51648676
 * http://openjdk.java.net/jeps/122
 * Remove the Permanent Generation
 * 类的元数据, 字符串池, 类的静态变量将会从永久代移除, 放入Java heap或者native memory
 */
public class RuntimeConstantPoolOOM {
    public static void main(String[] args) {
        List<String> strList = new ArrayList<>();
        int i = 0;
        while (true) {
            strList.add(String.valueOf(i++).intern());
        }
    }
}
